package weixin.app.test

import java.util.Date
import org.junit.Ignore
import org.junit.Test
import wechat.base.snd.QRCode
import wechat.base.snd.QRCodeManager
import wechat.base.snd.WCTemplateContent
import weixin.app.WXServiceAppFactoryDemo
import weixin.app.domain.DocumentDeliveryNotifyWeiXin
import weixin.app.domain.MeetingNotifyWeiXin
import weixin.app.domain.StandardQualificationNotifyWeiXin
import weixin.app.domain.HarzardCheckDueNotifyWeiXin
import weixin.app.domain.WXUserManager
import weixin.app.domain.*

import static weixin.app.test.ServiceAppDemoTest.*

class ServiceAppDemoTest {
//	static Logger logger = Logger::getLogger("ServiceAppTest")
	
	static String TEMPLATE_DISPATH_MSG_ID = "v_CkyFvYjwXJq525Au4Lv71rslPW5pwcye3vPtBNlTU";
	
	//模板ID: v_CkyFvYjwXJq525Au4Lv71rslPW5pwcye3vPtBNlTU
	//{{first.DATA}}
	//任务名称：{{keyword1.DATA}}
	//相关人员：{{keyword2.DATA}}
	//{{remark.DATA}}
	//你好，微OA有新任务
	//任务名称：报销单等待审批
	//相关人员：「微语科技」晋明会
	//请尽快进行处理
	@Test
	@Ignore
	def void serviceAppWorkflow(){
		println('test=========>serviceAppWorkflow')
		WXServiceAppFactoryDemo::serviceApp=>[
			createTemplateNews()=>[
				withTempId(TEMPLATE_DISPATH_MSG_ID)
				withData(new WCTemplateContent()=>[
					withFirstItem("你好，微OA有新任务")
					withKeyword1Item("报销单等待审批")
					withKeyword2Item('「微语科技」晋明会')
					withRemarkItem('请尽快进行处理')
				])
				withUrl("http://js.gwaycloud.com/meetingdetail?notificationid=22")
				send2Users(newArrayList('oQ19TwZ26yGx3Fvu4rAld1LvuWqI'))
				
			]
		]
	}
	
	@Test
	@Ignore	
	def void createSqrCode(){
		println('test=========>createSqrCode')
		new QRCodeManager(WXServiceAppFactoryDemo::serviceApp)=>[
			genPermTicket(new QRCode('11111')).getTicket("2222")
		]	
	}
	

	@Test
	@Ignore	
	def void getOpenId(){
		val code ="1"
		WXServiceAppFactoryDemo::serviceApp=>[
			println(getOpenId(code))
		]
	}
	
	@Test
	@Ignore
	def void sndTemplateMsgTest(){
		println('test=========>sndTemplateMsgTest')		
//		MeetingNotifyWeiXin::meetingNotify(newArrayList('oQ19TwZ26yGx3Fvu4rAld1LvuWqI', 'oQ19Twbt-Z8r4WPQj15VWMUicDM0'), new Date(),'园区', '体检相关事宜','609')
		MeetingNotifyWeiXin::meetingNotify(newArrayList('oQ19TwZ26yGx3Fvu4rAld1LvuWqI'), new Date(),'园区', '体检相关事宜','1')
	}

	@Test
	@Ignore
	def void sndTemplateDocumentDeliveryTest(){
		println('test=========>sndTemplateDocumentDeliveryTest')		
		DocumentDeliveryNotifyWeiXin::documentDeliverNotify(newArrayList('oQ19TwZ26yGx3Fvu4rAld1LvuWqI'), new Date(), '体检规定文档','1')
	}
	@Test
	@Ignore
	def void sndharzardCheckReportNotifyTest(){
		println('test=========>harzardCheckReportNotifyTest')		
		HarzardCheckDueNotifyWeiXin::harzardCheckReportNotify(newArrayList('oQ19TwZ26yGx3Fvu4rAld1LvuWqI'), new Date(), '体检规定文档', new Date())
	}


	
	@Test
	@Ignore
	def void getWeixinUsers(){
		println('test=========>getWeixinUsers')		
		WXServiceAppFactoryDemo::serviceApp=>[
			println(allWeixinUsers)
		]
	}
	@Test
	@Ignore	
	def void getDetailedUserInfo(){
		println('test=========>getDetailedUserInfo')		
		WXServiceAppFactoryDemo::serviceApp=>[
			println(getDetailedUserInfo('oQ19TwZ26yGx3Fvu4rAld1LvuWqI')) //Rock
//			println(getDetailedUserInfo('oQ19TwTss9u9srLWwTDaxiDGDoZg'))
//			println(getDetailedUserInfo('oQ19Twbt-Z8r4WPQj15VWMUicDM0'))// Zhang
		]
	}
	@Test
	@Ignore	
	def void SendNotification(){
//		println(SendNotification::sendMessage(newArrayList('oQ19TwZ26yGx3Fvu4rAld1LvuWqI'), 'title', 'body'))
	}

	@Test
	@Ignore	
	def void getWxUserName(){
		println(WXUserManager::getUserName('oQ19TwZ26yGx3Fvu4rAld1LvuWqI'))
	}	

	
//申请第一阶段，首先对于今年需要申请的企业（即下次评审的申请时间的年度是今年的企业）
//在今年的3月1日发个消息通知，通知该企业今年需要准备开展标准化评审工作。
	@Test
	@Ignore
	def void testStandardQualification(){
		StandardQualificationNotifyWeiXin::standardQualificationNotifyNotify(newArrayList('oQ19TwZ26yGx3Fvu4rAld1LvuWqI'), new Date(), '体检规定文档','1')
	}	
}
